<?php
require('config.php');
		
		$user_id=$_REQUEST['user_id'];
        $ymobile=$_REQUEST['ymobile'];
        $hmobile=$_REQUEST['hmobile'];
        $pan=$_REQUEST['pan'];
        if($pan==0)
        {
        	$sql="select * from `".$oto."_users` where `userPhone`='".$hmobile."' and `userFlag`='1' LIMIT 1";
			$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$cha_user[]=$row;//将取得的所有数据赋值给person_info数组
			}
			if(!isset($cha_user))
			{
				$sql="select * from `".$oto."_users` where `userPhone`='".$ymobile."' and userId='$user_id' and `userFlag`='1' LIMIT 1";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$cha_user2[]=$row;//将取得的所有数据赋值给person_info数组
				}
				if(!isset($cha_user2))
				{
					$data[0]['pan']=-3;
				}
				else
				{
					$sql="update ".$oto."_users set userPhone='{$hmobile}' where userId='{$user_id}'";
					$result=$db->query($sql);
					if($result)
					{
						$data[0]['pan']=1;
					}
					else
					{
						$data[0]['pan']=-2;
					}
				}
			}
			else
			{
				$data[0]['pan']=-1;
			}
        }
        else if($pan==1)
        {
        	$sql="select * from `".$oto."_users` where `userPhone`='".$hmobile."' and `userFlag`='1' LIMIT 1";
			$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$cha_user[]=$row;//将取得的所有数据赋值给person_info数组
			}
			if(!isset($cha_user))
			{
				$sql="update ".$oto."_users set userPhone='{$hmobile}' where userId='{$user_id}'";
				$result=$db->query($sql);
				if($result)
				{
					$data[0]['pan']=1;
				}
				else
				{
					$data[0]['pan']=-2;
				}
			}
			else
			{
				$data[0]['pan']=-1;
			}
        }
		echo json_encode($data);
?>